Expand description

Client for the Server-Sent Events protocol (aka EventSource).

use futures::{TryStreamExt};
use eventsource_client::{Client, SSE};
let mut client = eventsource_client::ClientBuilder::for_url("https://example.com/stream")?
    .header("Authorization", "Basic username:password")?
    .build();

let mut stream = Box::pin(client.stream())
    .map_ok(|event| match event {
        SSE::Comment(comment) => println!("got a comment event: {:?}", comment),
        SSE::Event(evt) => println!("got an event: {}", evt.event_type)
    })
    .map_err(|e| println!("error streaming events: {:?}", e));

Structs

ClientBuilder provides a series of builder methods to easily construct a Client.
A connector for the http scheme.
Configuration for a Client’s reconnect behaviour.

Enums

Error type returned from this library’s functions.

Constants

Maximum amount of redirects that the client will follow before giving up, if not overridden via ClientBuilder::redirect_limit.

Traits

Client is the Server-Sent-Events interface. This trait is sealed and cannot be implemented for types outside this crate.

Type Definitions

Represents a Pin’d Send + Sync stream, returned by Client’s stream method.